package com.untour.im.client.listener;

import com.untour.im.client.ClientArtisan;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;

public class ClientChannelFutureListener implements ChannelFutureListener {

    @Override
    public void operationComplete(ChannelFuture channelFuture) throws Exception {
        if (channelFuture.isSuccess()) {
            System.out.println("连接服务端成功");
            Channel channel = channelFuture.channel();
            // 连接之后，假设再这里发起各种操作指令，采用异步线程开始发送各种指令，发送数据用到的的channel是必不可少的
            ClientArtisan.sendActionCommand(channel);
        } else {
            channelFuture.channel().pipeline().fireChannelInactive();
        }
    }
}
